package com.example.computertms.servers.impl;

import com.example.computertms.mapper.ComputerTypeMapper;
import com.example.computertms.pojo.ComputerType;
import com.example.computertms.servers.ComputerTypeServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ComputerTypeServerImpl implements ComputerTypeServer {

    @Autowired
    private ComputerTypeMapper computerTypeMapper;

    @Override
    @Transactional
    public List<ComputerType> foundByComputerId(String computerId) {
        return computerTypeMapper.foundByComputerId(computerId);
    }

    @Override
    @Transactional
    public List<ComputerType> foundByName(String name) {
        return computerTypeMapper.foundByName(name);
    }

    @Override
    @Transactional
    public void addComputerType(ComputerType computerType) {
        computerTypeMapper.addComputerType(computerType.getComputerId(),computerType.getName(),computerType.getBrand(),
                computerType.getType(),computerType.getPrices(),computerType.getMainBoard(),computerType.getGraphicsCard(),computerType.getHardDisk(),
                computerType.getInternalStorage(),computerType.getCpu(),computerType.getMerchant(),computerType.getImgSrc());

    }

    @Override
    @Transactional
    public void changeComputerTypeByComputerId(ComputerType computerType) {
        computerTypeMapper.changeComputerTypeByComputerId(computerType.getComputerId(),computerType.getName(),computerType.getBrand(),
                computerType.getType(),computerType.getPrices(),computerType.getMainBoard(),computerType.getGraphicsCard(),computerType.getHardDisk(),
                computerType.getInternalStorage(),computerType.getCpu(),computerType.getMerchant(),computerType.getImgSrc());
    }

    @Override
    @Transactional
    public void deleteComputerTypeByComputerId(String computerId) {
        computerTypeMapper.deleteComputerTypeByComputerId(computerId);
    }

    @Override
    public List<ComputerType> foundAll() {
        return computerTypeMapper.foundAll();
    }
}
